<?php
session_start();
if (!isset($_REQUEST['mobile1']))
    header('location:index.php');
?>
<!DOCTYPE HTML>
<html>

    <head>
        <title>3D|Didongday 3D- Di động đây</title>
        <?php include('modules/page_head.php'); ?>
        <style type="text/css">
            .form_settings input{
                width : 100px;
            }
            .form_settings .submit{
                background:url(style/button_background.png);
                background-color:#FFF;
                display:block;
                color: #555555;
                font-weight:bold;
                height:40px;
                line-height:29px;
                margin: 0px 0px 14px 0px;
                text-decoration:none;
                width:100px;
            }
            input submit:hover.button{
                color:#0066CC;
                background-image:;
            }
            .compare{
                background:url(style/) no-repeat 5px 8px;
                text-align:center;
                display:block;
            }
            table tr td {
                border-top: 1px solid black;
            }
        </style>
    </head>

    <body>
        <div id="main">
            <div id="header">
                <div id="logo">
                    <h1><a href="mainpage.html">Didongde</a></h1>
                    <div class="slogan">Where you can find your own best suitable mobile</div>
                    <?php include_once('modules/logo_header.php'); ?>
                </div>
                <div id="menubar">
                    <?php include_once('modules/menubar.php'); ?>
                </div>
            </div>
            <div id="site_content">
                <div id="sidebar_container">
                    <h2>Tìm kiếm nhanh</h2>
                    <div class="sidebar">
                        <?php
                        include ("modules/quick_search.php");
                        show_manu();
                        ?>
                    </div>
                    <div class="sidebar">
                        <?php show_price(); ?>
                    </div>
                </div>
                <div id="content">
                    <?php
                    //include ("modules/connection.php");
                    include ("modules/mobile_list_select.php");
                    $conn = connectDB();
                    $query_mobile = "select model from mobilephone order by model asc";
                    $prepared_list = $conn->prepare($query_mobile);
                    ?>

                    <div class="form_settings">
                        <form action="#" method="get">
                            <table border="1">
                                <tr>
                                    <td width="150"></td>
                                    <td width="400">
                                        <select name="mobile1" style="width:200px">
                                            <?php
                                            if (isset($_GET['mobile1']))
                                                $model1 = $_GET['mobile1'];
                                            else {
                                                $model1 = "";
                                                echo "<option value=\"-1\">Chọn điện thoại</option>";
                                            }
                                            get_select_list($prepared_list, $model1)
                                            ?>
                                        </select></td>
                                    <td width="400">
                                        <select name="mobile2" selected="selected" style="width:200px">
                                            <?php
                                            if (isset($_GET['mobile2']))
                                                $model2 = $_GET['mobile2'];
                                            else {
                                                $model2 = null;
                                                echo "<option value=\"-1\">Chọn điện thoại</option>";
                                            }
                                            get_select_list($prepared_list, $model2);
                                            ?>
                                        </select></td>
                                    <td><button title="Tiến hành so sánh" class="submitIMG" name="compare" type="submit" value="compare" onmouseover="changepic(this)" onmouseout="returnpic(this)" style="margin-top:5px;"><img class="submitIMG" alt="So sánh" src="style/images/compare-button.png"/></button></td>
                                </tr>
                                <?php
                                $query1 = "select * from mobilephone where model = '$model1'";
                                $query2 = "select * from mobilephone where model = '$model2'";


                                $prepared1 = $conn->prepare($query1);
                                $prepared1->execute();
                                $result1 = $prepared1->fetch();

                                $prepared2 = $conn->prepare($query2);
                                $prepared2->execute();
                                $result2 = $prepared2->fetch();
                                ?>
                                <tr>
                                    <td>Model</td>
                                    <td><?php echo $result1['model'] ?></td>
                                    <td><?php echo $result2['model'] ?></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>Ảnh</td>
                                    <td><a href="show_mobile.php?mbname=<?php echo $result1['model']; ?>"><img class=mb_img src=<?php echo $result1['picture_path']; ?> alt="<?php echo $result1['model'] ?>"></a></td>
                                    <td><?php if ($result2) { ?><a href="show_mobile.php?mbname=<?php echo $result2['model']; ?>"><img class=mb_img src=<?php echo $result2['picture_path']; ?> alt="<?php echo $result2['model'] ?>"></a><?php } ?></td>
                                    <td><textarea style="width:80px;" placeholder="Ghi chú của bạn"></textarea></td>
                                </tr>
                                <tr>
                                    <td>Giá</td>
                                    <td><b><?php echo number_format($result1['price'], 3, ',', ',') . " VNĐ"; ?></b></td>
                                    <td><b><?php if ($result2)
                                    echo number_format($result2['price'], 3, ',', ',') . " VNĐ"; ?></b></td>
                                    <td><textarea style="width:80px;" placeholder="Ghi chú của bạn"></textarea></td>
                                </tr>
                                <tr>
                                    <td>Khuyến mại</td>
                                    <td><b><?php echo $result1['promotions'] ?></b></td>
                                    <td><b><?php echo $result2['promotions'] ?></b></td>
                                    <td><textarea style="width:80px;" placeholder="Ghi chú của bạn"></textarea></td>
                                </tr>
                                <tr>
                                    <td>Bảo hành</td>
                                    <td><b><?php echo $result1['warranty'] ?></b></td>
                                    <td><b><?php echo $result2['warranty'] ?></b></td>
                                    <td><textarea style="width:80px;" placeholder="Ghi chú của bạn"></textarea></td>
                                </tr>
                                <tr>
                                    <td>Hệ điều hành</td>
                                    <td><b><?php echo $result1['os'] ?></b></td>
                                    <td><b><?php echo $result2['os'] ?></b></td>
                                    <td><textarea style="width:80px;" placeholder="Ghi chú của bạn"></textarea></td>
                                </tr>
                                <tr>
                                    <td>Giải trí</td>
                                    <td><b><?php echo $result1['entertainment'] ?></b></td>
                                    <td><b><?php echo $result2['entertainment'] ?></b></td>
                                    <td><textarea style="width:80px;" placeholder="Ghi chú của bạn"></textarea></td>
                                </tr>
                                <tr>
                                    <td>Màn hình</td>
                                    <td><b><?php echo $result1['screen'] ?></b></td>
                                    <td><b><?php echo $result2['screen'] ?></b></td>
                                    <td><textarea style="width:80px;" placeholder="Ghi chú của bạn"></textarea></td>
                                </tr>
                                <tr>
                                    <td>Pin</td>
                                    <td><b><?php echo $result1['battery'] ?></b></td>
                                    <td><b><?php echo $result2['battery'] ?></b></td>
                                    <td><textarea style="width:80px;" placeholder="Ghi chú của bạn"></textarea></td>
                                </tr>
                                <tr>
                                    <td>Kiểu dáng</td>
                                    <td><b><?php echo $result1['appearance'] ?></b></td>
                                    <td><b><?php echo $result2['appearance'] ?></b></td>
                                    <td><textarea style="width:80px;" placeholder="Ghi chú của bạn"></textarea></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
            <div id="footer">
                <?php include('modules/footer.php'); ?>
            </div>
    </body>
</html>
